package com.neusoft.neuiotms.dcom.model.change;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.validator.constraints.Length;

import com.neusoft.bizcore.web.jpa.model.AbstractAuditModel;
import com.neusoft.bizcore.web.jpa.model.Comment;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@Entity
@Table(name = "neuiot_change_ci_relation")
@org.hibernate.annotations.Table(appliesTo = "neuiot_change_ci_relation", comment = "变更配置项关系表")
public class ChangeCiRelation extends AbstractAuditModel {

    private static final long serialVersionUID = 1L;

    @Length(max = 255, message = "描述不能超过{max}位")
    @Column(length = 255, nullable = false)
    @Comment("varchar(255) NOT NULL COMMENT '描述'")
    private String description;

    @Length(max = 255, message = "源实例不能超过{max}位")
    @Column(length = 255, nullable = false)
    @Comment("varchar(255) NOT NULL COMMENT '源实例'")
    private String sourceInstance;

    @Length(max = 255, message = "源实例名称不能超过{max}位")
    @Column(length = 255, nullable = true)
    @Comment("varchar(255) DEFAULT NULL COMMENT '源实例名称'")
    private String srouceInstanceDesc;

    @Length(max = 255, message = "目标实例不能超过{max}位")
    @Column(length = 255, nullable = false)
    @Comment("varchar(255) NOT NULL COMMENT '目标实例'")
    private String targetInstance;

    @Length(max = 255, message = "目标实例名称不能超过{max}位")
    @Column(length = 255, nullable = true)
    @Comment("varchar(255) DEFAULT NULL COMMENT '目标实例名称'")
    private String targetInstanceDesc;

    @Length(max = 255, message = "所属关联不能超过{max}位")
    @Column(length = 255, nullable = false)
    @Comment("varchar(255) NOT NULL COMMENT '所属关联'")
    private String relation;

    @Length(max = 255, message = "所属关联名称不能超过{max}位")
    @Column(length = 255, nullable = true)
    @Comment("varchar(255) DEFAULT NULL COMMENT '所属关联名称'")
    private String relationDesc;

    @Length(max = 255, message = "关系id不能超过{max}位")
    @Column(length = 255, nullable = true)
    @Comment("varchar(255) DEFAULT NULL COMMENT '关系id'")
    private String relationId;

    @Column(length = 1024, nullable = true)
    @Comment("varchar(1024) DEFAULT NULL COMMENT '关系属性'")
    private String attrs;

    /**
     * 对于已存在关系，工单运行过程中，只是标记一下是否删除，待工单结束是才会真正执行删除操作。 对于新建立的关系，当选择删除时及为真正的删除。
     */
    @Column(nullable = false)
    @Comment("bit NOT NULL COMMENT '是否删除（0 否 1 是）'")
    private Boolean deleteFlag;

    @Column(nullable = false)
    @Comment("bit NOT NULL COMMENT '是否新增（0 否 1 是）'")
    private Boolean addFlag;

    @Length(max = 255, message = "变更后描述不能超过{max}位")
    @Column(length = 255, nullable = true)
    @Comment("varchar(255) DEFAULT NULL COMMENT '变更后描述'")
    private String descriptionChange;

    @Column(length = 1024, nullable = true)
    @Comment("varchar(1024) DEFAULT NULL COMMENT '变更后关系属性'")
    private String attrsChange;

    @ManyToOne(targetEntity = ChangeImplementation.class)
    private ChangeImplementation changeImplementation;

    @Length(max = 255, message = "工作流TaskId不能超过{max}位")
    @Column(length = 255, nullable = true)
    @Comment("varchar(255) DEFAULT NULL COMMENT '工作流TaskId'")
    private String taskId;

}
